{config_load file="inserat.txt" section=addInserat}
{config_load file="inserat.txt" section=inseratInfo}

<div id="contentFull">
{* check if the user may add/edit listings *}
{if $noaccess}
    <h2>{#listing#} "{$data.title}" {#cantedit#}!</h2>
    
    <div id="errorText">
        <p>{#nep1#}</p>
        <p>{#nep2#}</p>
    </div>
    
{* yes we can *}
{else}
    {* make sure the title matched the action *}
    {if $edit}
        <h2>{#edittitle#} "{$data.title}"</h2>
        <p>{#editnote1#} <a href="{$INA.this}">{$INA.this}</a></p>
        <p>{#editnote2#}</p>
        
    {else}
        <h2>{#addtitle#}</h2>
        <p>{#postTo#} 
        <strong>
                {foreach from=$postingTo item=crumb name=crumbs}
            		{if $smarty.foreach.crumbs.last}
            		    {$crumb.title}
            		{else}
                		{$crumb.title} > 
            		{/if}
        		{/foreach}
        </strong><small>(<a href="{$INA.root}">{#pickCat#}</a>)</small></p>
    {/if}
    
    {if $error}
        <div id="errorText">
        {#correrr#}
        </div>
    {/if}
    
    
    <form name="addNewInserat" id="addNewInserat" enctype="multipart/form-data" method="post" action="{$INA.this}{if $edit}?do=edit&confirm={$smarty.get.confirm}{else}?add=true{/if}" onsubmit="disable('mainSubmitBut','{#pwait#}');">
        <fieldset>
            <legend>{#iInfo#}</legend>

            <!-- start type -->
        	<label>{#type#}</label>
        	<div id="type">
            	<table cellspacing="2" cellpadding="0">
            	<tr>
            		<td>
            		<input type="radio" name="type" value="1" id="typeSell" tabindex="1" {if !$smarty.post.type or $smarty.post.type == 1}checked="checked"{/if} />
            		</td><td><label for="typeSell" class="nobold">{#selling#}</label></td>
            	</tr><tr>
            		<td>
            		<input type="radio" name="type" value="2" id="typeBuy" tabindex="2" {if $smarty.post.type == 2 or $smarty.get.type == 2}checked="checked"{/if} />
            		</td><td><label for="typeBuy" class="nobold">{#buying#}</label></td>
            
            	</tr>
            	</table>
        	</div>
        	<!-- end type -->
        
        	<!-- start title -->
        	<label for="title">{#title#}</label>
        	<div id="titleInput">
        	   <table cellpadding="0" cellspacing="2"><tr><td>
        		<input type="text" maxlength="255" name="title" id="title" class="borders{if $error.title} error{/if}" tabindex="3" value="{$smarty.post.title}" />
        		</td>
				<!--
				<td>{#in#}</td>
				<td>   
					<select name="region" id="regionSelect" tabindex="4">
						<option value="Vienna">Vienna</option>
					</select>
				</td>
				-->
				</tr>
        	   {if $error.title}
            	    <tr><td colspan="2" class="errorMessage">
                        {#titleerror#}
                    </td></tr>
                {/if}
        	   </table>
        	</div>
        	<!-- end title -->
        	
            <!-- start price -->
        	<label for="pricenum">{#price#}</label>
        	<div id="priceInput">
            	<table cellspacing="0" cellpadding="2">
            	<tr>
            	    <td>
            		<select name="pricealt" id="pricealt" onchange="checkPrice();">
            			<option value="0" {if !$smarty.post.pricealt}selected="selected"{/if}>{#pickOption#}</option>
            			<option value="1" {if $smarty.post.pricealt == 1}selected="selected"{/if}>{#bestOffer#}</option>
            			<option value="2" {if $smarty.post.pricealt == 2}selected="selected"{/if}>{#contact#}</option>
            			<option value="3" {if $smarty.post.pricealt == 3}selected="selected"{/if}>{#exchange#}</option>
            			<option value="4" {if $smarty.post.pricealt == 4}selected="selected"{/if}>{#free#}</option>
            		</select>
            		</td>
            		<td id="pricenumtit">{#curr#}:</td><td>
            		<input type="text" maxlength="8" name="pricenum" id="pricenum" tabindex="5" class="borders {if $error.priceNum}error{/if}" value="{$smarty.post.pricenum}" />
            		</td><td style="color: #666;" id="pricenumhelp">{#currhelp#}</td>
            	</tr>
            	</table>
        	</div>
        	<!-- end price -->
        
        	<!-- start description -->
        	<label for="desc">{#desc#}</label>
			<table>
			<tr><td>
				<div id="description">
					<textarea name="desc" id="desc" rows="8" cols="50" class="myinput borders{if $error.desc} error{/if}" tabindex="7">{$smarty.post.desc}</textarea>
					<div id="descHelp">
						{if $error.desc}
							<span class="errorMessage">
							{#descerror#}<br />
							</span>
						{/if}
						{#descHelp#}
					</div>
				</div>
			</td><td valign="top">
				<div class="helpBox">
        		  <h4>{#tips#}:</h4>
        		  <ul>
        		      <li>{#tip1#}</li>
        		      <li>{#tip2#}</li>
        		  </ul>
        		</div>
			</td></tr>
			</table>
        	<!-- end description -->
        
        	<!-- picture upload -->
        	<label>{#pict#} ({#popt#})</label>
        	<div id="picture">
        	
            	{if $data.image == "t"}
            	   <div id="actualImage">
                	   <img src="{$INA.root}files/inserats/{$data.intime|date_format:"%Y/%m/%d/"}{$data.id}/thumb.jpg" alt="{#thumbImage#}" id="thumbImage" /><br />
                	   <input type="hidden" name="image" value="1" id="insImg" />
                	   [ <a href="{$INA.this}?{if $edit}do=edit&confirm={$smarty.get.confirm}{else}add=true{/if}&action=erasepict">{#delete#}</a> ]
            	   </div>
            	{/if}
        		<input type="hidden" name="MAX_FILE_SIZE" value="204800" />
        		<input type="file" name="pict" tabindex="8" class="myinput {if $error.image or $error.image2} error{/if}" />
				{if $error.image}
					<div class="errorMessage">
					{#imageerror#}
					</div>
				{elseif $error.image2}
					<div class="errorMessage">
					{#imageerror2#}
					</div>
				{/if}
        	</div>
        	<!-- end picture upload -->
          
        </fieldset>
        
        {* when a listing is edited, the e-mail address cannot be changed *}
        {* moreover, one does not need to confirm he/she is human again *}
        {if !$edit}
            <!-- email -->
        	<fieldset>
				<legend>{#cInfo#}</legend>

            	<label for="insMail">{#email#}</label>
            	<div id="email">
            		<input type="text" id="insMail" maxlength="255" name="mail" class="myinput borders{if $error.mail} error{/if}" tabindex="9" value="{$smarty.post.mail}" />
            		{if $error.mail}
            		    <div class="errorMessage">
            		    {#mailerror#}
                		</div>
            		{/if}
            		<p>{#ehelp1#}</p>
            		<p>{#ehelp2#}</p>
            	</div>
        	</fieldset>
        	<!-- end email -->
    
        
        	<!-- anti spam picture -->
        	<fieldset>
        		<legend>{#pBot#}</legend>

        		<label for="confNum">{#antiSpam#}</label>
        		<div id="antiSpam">
        			<p>{#aSpamHelp#}</p>
        			<table cellspacing="0" cellpadding="2">
        			<tr><td>&nbsp;</td><td>{#cTag#}</td></tr>
        			<tr><td align="center"><img src="{$INA.root}image/confirm.gif" alt="nospam" id="nospam" /></td><td valign="middle">
        			     <input type="text" maxlength="5" name="confNum" class="borders{if $error.confNum} error{/if}" id="confNum" tabindex="10" value="{$smarty.post.confNum}" />
        			</td></tr>
        			{if $error.confNum}
        			    <tr><td colspan="2" class="errorMessage">
        			         {#codeerror#}
        			    </td></tr>
            		{/if}
        			</table>
        		</div>
        		
        		<div id="submitButtons">
        		  <input type="submit" name="go" value="{#postit#}" id="mainSubmitBut" tabindex="11" />
				  <ul>
        			<li>{#ifClick#} <a href="{$INA.root}tac.html">{#toc#}</a>.</li>
					<li><a href="{$INA.root}datenschutz.html">Datenschutzerkl&auml;rung</a></li>
				  </ul>
        		</div>
        	</fieldset>
        	<!-- end anti spam picture -->
    	{else}
        	<fieldset>
        		<div id="submitButtons">
        		  <input type="submit" name="go" value="{#updateit#}" id="mainSubmitBut" tabindex="11" />
        		</div>
        	</fieldset>
    	{/if}
    </form>
{/if}
</div>
<script language="JavaScript" type="text/javascript">
	checkPrice();
</script>